#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>

int main(){
	pid_t pid_A=fork();
	if(pid_A==-1){
		perror("fork_A");
		exit(1);
	}
	if(pid_A==0){
		printf("pid_A\n");
		pause();
		printf("B OK\n");
		exit(0);
	}else{
		sleep(1);
		int ret=kill(pid_A,SIGKILL);
		if(ret==-1){
			perror("kill_A");
			exit(1);
		}
		pid_t pid_B=fork();
		if(pid_B==-1){
			perror("fork_B");
			exit(1);
		}
		if(pid_B==0){
			 printf("pid_B\n");
			 raise(SIGSTOP);
			 printf("B OK\n");
			 exit(0);
		}
		sleep(1);
		ret=kill(pid_B,SIGKILL);
		if(ret==-1){
			perror("kill_B");
			exit(1);
		}
		wait(NULL);
		wait(NULL);
		printf("main OK\n");
	}
	return 0;
}

